function showPointCloudWithVrml(toFilename,allpf)
% showPointCloudWithVrml Write a VRML (.wrl) file from matrix allpf
% toFilename: The output file name. You should use the .wrl extension
% allpf: A n-by-6 matrix, where n is the number of 3D points that you wish
% to write to the file. Each row of the matrix is in the form [x y z r g
% b], where x y z are the 3D point locations and r g b are the RBG color
% values scaled from 0 to 1 (black to full color)
   

disp('Writing point cloud\n')
  tic
  %% Now write a vrml file
  FILE = fopen(toFilename,'w');  
  fprintf(FILE,'#VRML V2.0 utf8\nNavigationInfo {\ntype ["EXAMINE","WALK","FLY"] \n}\nGroup {\n children [\n Shape {\n    geometry PointSet { \n      coord Coordinate{ \n      point [ \n');
	  fprintf(FILE,'%f %f %f,\r\n',allpf(:,[1 2 3])');
		  fprintf(FILE,']\n}\ncolor Color {\n color [\n');
          salp= size(allpf);
if(salp(2)==3)
						   fprintf(FILE,'%f %f %f,\r\n',ones(salp(1),3)');
else
          
						   fprintf(FILE,'%f %f %f,\r\n',allpf(:,[4 5 6])');
end
                           fprintf(FILE,']\n}  \n}\n appearance Appearance {\n      material \nMaterial {\n \n}\n \n}\n  }\nViewpoint \n{\n   description \"currentview\"\n  position 22.5 4.57 0\n orientation -0.196181 0.905479 0.376325 2.10916 } \n]\n}\n');
  fclose(FILE);
   toc

% command = ['C:/programme/vcg/meshlab/meshlab.exe ' toFilename];
% system(command);

  



